package com.dailyblue.java.spring.mybatis.test;

import com.dailyblue.java.spring.mybatis.bean.Dept;
import com.dailyblue.java.spring.mybatis.bean.Emp;
import com.dailyblue.java.spring.mybatis.service.DeptService;
import com.dailyblue.java.spring.mybatis.service.EmpService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.List;

public class App {
    // 注解写法 常用 重点
    public static void a(){
        ApplicationContext beans = new AnnotationConfigApplicationContext("com.dailyblue.java.spring.mybatis");
        EmpService empService = beans.getBean(EmpService.class);
        List<Emp> list = empService.findAllEmp();
        for (Emp emp:list){
            System.out.println(emp);
        }
    }
    // XML写法 非常用一般就在动态SQL中使用
    public static void b(){
        ApplicationContext beans = new AnnotationConfigApplicationContext("com.dailyblue.java.spring.mybatis");
        DeptService deptService = beans.getBean(DeptService.class);
        List<Dept> list = deptService.findAllDept();
        for(Dept dept:list){
            System.out.println(dept);
        }
    }
    public static void main(String[] args) {
        b();
    }
}
